//
//  LoginAPI.swift
//  LeGou
//
//  Created by lxm on 2022/7/23.
//
import Foundation

enum LoginAPI {
    /// 是否已经注册
    case hadRegister(_ param : [String : Any])
    /// 发送验证码
    case sendCode(_ param : [String : Any])
    /// 手机注册/验证码登录
    case loginOrRegister(_ param : [String : Any])
    /// 注册设置密码城市
    case setPsdAndCity(_ param : [String : Any])
    /// 密码登录
    case psdLogin(_ param : [String : Any])
    /// 重设置密码
    case psdReset(_ param : [String : Any])
    /// 微信注册
    case wxRegister(_ param : [String : Any])
    /// 微信登录
    case wxLogin(_ param : [String : Any])
}

extension LoginAPI: ZMApiProvider {
    func BaseUrl() -> String {
        return baseUrl
    }
 
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
            case .hadRegister(let pa):
                return ("/api/front/login/isExist", .get, pa, false)
            case .sendCode(let pa):
                return ("/api/front/sendCode", .post, pa, false)
            case .loginOrRegister(let pa):
                return ("/api/front/login/mobile", .post, pa, true)
            case .setPsdAndCity(let pa):
                return ("/api/front/user/pwd/set", .post, pa, true)
            case .psdLogin(let pa):
                return ("/api/front/login/pwd", .post, pa, true)
            case .psdReset(let pa):
                return ("/api/front/login/pwd/reset", .post, pa, true)
            case .wxRegister(let pa):
                return ("/api/front/login/regWx", .post, pa, true)
            case .wxLogin(let pa):
                return ("/api/front/login/wx", .post, pa, true)
        }
    }
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func singleRequest() -> Bool {
        if developMode == 1 {
            switch self {
            case .sendCode,
                 .hadRegister:
                return true
            default:
                return false
            }
        } else {
            return false
        }
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }
    
}
